package com.hmall.search.web;

import com.hmall.search.pojo.PageResult;
import com.hmall.search.pojo.RequestParams;
import com.hmall.search.service.IItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/search")
public class ItemController {
    @Autowired
    private IItemService iItemService;

    @GetMapping("/suggestion")
    public List<String> getSuggestions(@RequestParam("key") String prefix){
        return iItemService.getSuggestions(prefix);
    }
    @PostMapping("filters")
    public Map<String, List<String>> getFilters(@RequestBody RequestParams params){
        return iItemService.getFilters(params);
    }
    @PostMapping("/list")
    public PageResult search(@RequestBody RequestParams params) {
        return iItemService.search(params);
    }
}
